\documentclass{beamer}

\usepackage{fontspec}
\usepackage{xcolor}
\setmonofont{JetBrains Mono}[
    Contextuals = Alternate,
    Ligatures = TeX,
]
% \setmonofont{Consolas}
\usepackage{listings}
\lstset{
    basicstyle = \ttfamily,
    columns = flexible,
}

\begin{document}
\begin{frame}[fragile]
    \begin{lstlisting}[language = C++, numbers=left,
        numberstyle=\tiny,keywordstyle=\color{blue!70},
        commentstyle=\color{red!50!green!50!blue!50},frame=shadowbox,
        rulesepcolor=\color{red!20!green!20!blue!20},basicstyle=\ttfamily]
        void work();
        std::thread my_thread(work);
    \end{lstlisting}
    some word.
\end{frame}
\end{document}